#pragma GCC optimize(2)
#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
int main()
{
	IOS;
	int t;
	cin>>t;
	while(t--)
	{
		int n,k;
		cin>>n>>k;
		vector<pii> a(n);
		vector<int> b(n);
		for(int i=0;i<n;i++)
		{
			cin>>a[i].first;
			b[i]=a[i].first;
			a[i].second=i;
		}
		sort(a.begin(),a.end());
		int p1=0;
		int p2=0;
		int mi=1<<30;
		for(int i=0;i<a.size()-1;i++)
		{
			int x1=a[i].first;
			int y1=a[i].second;
			int x2=a[i+1].first;
			int y2=a[i+1].second;
			if((x1^x2)<mi)
			{
				mi=(x1^x2);
				p1=y1;
				p2=y2;
			} 
		}
		int x=0;
		for(int i=k-1;i>=0;i--)
		{
			x*=2;
			int b1=((b[p1]>>i)&1);
			if(b1==0) x+=1;
			
		}
		cout<<p1+1<<' '<<p2+1<<' '<<x<<endl;
	}

	return 0;
}

